<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../layui/css/layui.css" media="all">
    <script type="text/javascript" src="../layui/layui.js"></script>
    <script type="text/javascript" src="../js/jquery-1.12.2.min.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
    <style>
        .gaga {
            margin-left: 30%;
            margin-top: 5%;
        }
    </style>
</head>
<body>
<form class="layui-form layui-form-pane gaga" id="listForm">
    <div class="layui-form-item">
        <label class="layui-form-label">床位数</label>
        <div class="layui-input-inline">
            <input type="text" name="number" lay-verify="required" autocomplete="off" placeholder="请输入"
                   class="layui-input">
        </div>
    </div>
<!--    <div class="layui-form-item">
        <label class="layui-form-label">选择科室</label>
        <div class="layui-input-inline">
            <select name="deptId" lay-verify="required" lay-search="">
                <option value="">请选择</option>
                <option value="1">呼吸内科</option>
                <option value="2">消化内科</option>
                <option value="3">心内科</option>
                <option value="4">血液科</option>
                <option value="5">小儿科</option>
                <option value="6">内分泌科</option>
                <option value="7">神经内科</option>
                <option value="8">感染科</option>
                <option value="9">骨科</option>
                <option value="10">神经外科</option>
                <option value="11">肝胆外科</option>
                <option value="12">烧伤科</option>
                <option value="13">妇科</option>
                <option value="14">产科</option>
            </select>
        </div>
    </div>-->
    <div class="layui-form-item">
        <label class="layui-form-label">房间类型</label>
        <div class="layui-input-inline">
            <select name="roomTypeId" lay-verify="required" lay-search="">
                <option value="">请选择</option>
                <option value="1">icu病房</option>
                <option value="2">ccu病房</option>
                <option value="3">VIP病房</option>
                <option value="4">普通病房</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <button class="layui-btn" lay-submit="" lay-filter="demo2">提交</button>
    </div>
</form>


<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

        form.on('submit(demo2)', function (data) {
            $.ajax({
                type: "post",
                url: "/hospital/manager/room/add.do",
                data: data.field,
                dataType: "json",
                success: function (data) {
                    if (data.code === 1) {
                        $('#listForm')[0].reset();
                        alert(data.info)
                    } else {
                        alert(data.info)
                    }
                }
            });
            return false;
        });
    });
</script>
</body>
</html>